#include "system.h"
#include "SysTick.h"
#include "led.h"
#include "usart.h"
#include "tftlcd.h"
#include "picture.h"
#include "MPU6050.h"
#include "Delay.h"


uint8_t ID;								//�������ڴ��ID�ŵı���
int16_t AX, AY, AZ, GX, GY, GZ;			//�������ڴ�Ÿ������ݵı���

/*******************************************************************************
* �� �� ��         : main
* ��������		   : ������
* ��    ��         : ��
* ��    ��         : ��
*******************************************************************************/
int main()
{
	u8 i=0;
	u16 color=0;
	MPU6050_Init();		//MPU6050��ʼ��
	
	SysTick_Init(72);
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);  //�ж����ȼ����� ��2��
	LED_Init();
	USART1_Init(115200);
	TFTLCD_Init();			//LCD��ʼ��
	ID = MPU6050_GetID();				//��ȡMPU6050��ID��,
	FRONT_COLOR=BLACK;
	
	LCD_ShowString(10,10,tftlcd_data.width,tftlcd_data.height,24,"Hello World!");
	LCD_ShowString(10,50,tftlcd_data.width,tftlcd_data.height,24,"ID:");
	LCD_ShowNum(50,50,ID,3,24);

	while(1)
	{
		i++;
		if(i%100==0)
		{
			MPU6050_GetData(&AX, &AY, &AZ, &GX, &GY, &GZ);		//��ȡMPU6050������
			LED1=!LED1;
			printf("\r\n");
			printf("AX:%d\r\n",AX);
			printf("AY:%d\r\n",AY);
			printf("AZ:%d\r\n",AZ);
			printf("GX:%d\r\n",GX);
			printf("GY:%d\r\n",GY);
			printf("GZ:%d\r\n",GZ);
		}
//		MPU6050_GetData(&AX, &AY, &AZ, &GX, &GY, &GZ);		//��ȡMPU6050������
//		
//		LCD_ShowString(10,130,tftlcd_data.width,tftlcd_data.height,24,"AY:");
//		LCD_ShowString(10,160,tftlcd_data.width,tftlcd_data.height,24,"AZ:");
//		LCD_ShowString(10,190,tftlcd_data.width,tftlcd_data.height,24,"GX:");
//		LCD_ShowString(10,220,tftlcd_data.width,tftlcd_data.height,24,"GX:");
//		LCD_ShowString(10,250,tftlcd_data.width,tftlcd_data.height,24,"GZ:");


//		LCD_ShowNum(60,100,AX,4,24);
//		LCD_ShowNum(60,130,AY,4,24);
//		LCD_ShowNum(60,160,AZ,4,24);
//		LCD_ShowNum(60,190,GX,4,24);
//		LCD_ShowNum(60,220,GX,4,24);
//		LCD_ShowNum(60,250,GZ,4,24);
		delay_ms(100);
	}
}
